<template>
  <div class="person">
    <h2>我是Person组件</h2>
    <h3>姓名：{{name}}</h3>
    <h3>真实年龄：{{age.originAge}}</h3>
    <h3>对外年龄：{{age.foreignAge}}</h3>
    <button @click="changeName">改名</button>
    <button @click="changeOriginAge">改真实年龄</button>
    <button @click="changeForeignAge">改对外年龄</button>
    <button @click="changeAge">改年龄对象</button>
  </div>
</template>

<script>
  export default {
    name:'Person',
    props:['name','age'],
    methods: {
      changeName(){
        this.name = '尼古拉斯峰'
      },
      changeOriginAge(){
        this.age.originAge = 29
      },
      changeForeignAge(){
        this.age.foreignAge = 22
      },
      changeAge(){
        this.age = {originAge:900,foreignAge:800}
      }
    },
  }
</script>

<style scoped>
  .person {
    background-color: skyblue;
    padding: 20px;
  }
</style>